import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Lobster here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Lobster extends Actor
{
    /**
     * Act - do whatever the Lobster wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    private int mark = 1;
    public void act() 
    {
        move(5);
        turnAtEdge();
        randomTurn();
        animation();
        if(isTouching(Crab.class)){
            removeTouching(Crab.class);
            Greenfoot.playSound("au.wav");
            Greenfoot.stop();
        }
    } 
    public void turnAtEdge(){
        if(isAtEdge())
            turn(15);
    }
    public void randomTurn(){
        if(Greenfoot.getRandomNumber(100)<30){
            turn(Greenfoot.getRandomNumber(60)-30);
        }
        
    }
    public void animation(){
        if(mark == 1){
            setImage("lobster2.png");
            mark = 2;
        } else{
            setImage("lobster.png");
            mark = 1;
        }
    }
}
